function varargout = Defaults_v001(varargin)
% DEFAULTS_V001 M-file for Defaults_v001.fig
%      DEFAULTS_V001, by itself, creates a new DEFAULTS_V001 or raises the existing
%      singleton*.
%
%      H = DEFAULTS_V001 returns the handle to a new DEFAULTS_V001 or the handle to
%      the existing singleton*.
%
%      DEFAULTS_V001('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DEFAULTS_V001.M with the given input arguments.
%
%      DEFAULTS_V001('Property','Value',...) creates a new DEFAULTS_V001 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Defaults_v001_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Defaults_v001_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Defaults_v001

% Last Modified by GUIDE v2.5 02-Sep-2003 14:58:07

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Defaults_v001_OpeningFcn, ...
                   'gui_OutputFcn',  @Defaults_v001_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Defaults_v001 is made visible.
function Defaults_v001_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Defaults_v001 (see VARARGIN)

% Choose default command line output for Defaults_v001
load 'C:\Data\AppDefaults\DefaultSettings';

handles.Defaults = Defaults;
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Defaults_v001 wait for user response (see UIRESUME)
% uiwait(handles.Defaults);

load_prev_defaults(hObject, eventdata, handles);

% --- Outputs from this function are returned to the command line.
function varargout = Defaults_v001_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



% --- Executes during object creation, after setting all properties.
function FreqChan_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FreqChan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.

load 'C:\Data\AppDefaults\DefaultSettings';
set(hObject,'String',Defaults(1,2));

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function FreqChan_Callback(hObject, eventdata, handles)
% hObject    handle to FreqChan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of FreqChan as text
%        str2double(get(hObject,'String')) returns contents of FreqChan as a double

handles.FreqChan = str2double(get(hObject,'String'));
guidata(hObject, handles);


% ---Executes during object creation, after setting all properties.
function RefChan_CreateFcn(hObject, eventdata, handles)
% hObject    handle to RefChan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.

load 'C:\Data\AppDefaults\DefaultSettings';
set(hObject,'String',Defaults(2,2));

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function RefChan_Callback(hObject, eventdata, handles)

handles.RefChan = str2double(get(hObject,'String'));
guidata(hObject, handles);
% hObject    handle to RefChan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of RefChan as text
%        str2double(get(hObject,'String')) returns contents of RefChan as a double


% --- Executes during object creation, after setting all properties.
function FreqRes_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FreqRes (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.

load 'C:\Data\AppDefaults\DefaultSettings';
set(hObject,'String',Defaults(3,2));

if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


function FreqRes_Callback(hObject, eventdata, handles)
% hObject    handle to FreqRes (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of FreqRes as text
%        str2double(get(hObject,'String')) returns contents of FreqRes as a double
handles.PSDRes = str2double(get(hObject,'String'));
guidata(hObject, handles);

% --- Executes on button press in Okay.
function Okay_Callback(hObject, eventdata, handles)
% hObject    handle to Okay (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
Defaults=handles.Defaults;
Defaults{1,2} = handles.FreqChan;
Defaults{2,2} = handles.RefChan;
Defaults{3,2} = handles.PSDRes;

save('C:\Data\AppDefaults\DefaultSettings','Defaults');
close (Defaults_v001);


% --- Executes on button press in Cancel.
function Cancel_Callback(hObject, eventdata, handles)
% hObject    handle to Cancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close (Defaults_v001);

function load_prev_defaults(hObject, eventdata, handles)

handles.FreqChan = handles.Defaults{1,2};
handles.RefChan = handles.Defaults{2,2};
handles.PSDRes = handles.Defaults{3,2};
guidata(hObject, handles);

